//
//  XLMainTabBarController.swift
//  XLVeibo
//
//  Created by macbook on 16/6/23.
//  Copyright © 2016年 buWangChuXing. All rights reserved.
//

import UIKit

class XLMainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        //自定义tab
        let tabBar = XLTabBar()
        tabBar.XLDelegate = self
       
        //通过KVC给只读属性赋值
        setValue(tabBar, forKey: "tabBar")
        
        
        
       addChildViewController(XLHomeTableViewController(), title: "首页", imgName: "tabbar_home")
        addChildViewController(XLMesssageTableViewController(), title: "消息", imgName: "tabbar_message_center")
        addChildViewController(XLDiscoverTableViewController(), title: "发现", imgName: "tabbar_discover")
        addChildViewController(XLCommonTableViewController(), title: "我", imgName: "tabbar_profile")
        
        
    }
    

    func addChildViewController(vc:UIViewController,title:String,imgName:String){
    
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imgName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")
        
        let navC = UINavigationController(rootViewController: vc)
        addChildViewController(navC)
        
    
    
    }

}

// MARK: - 中间按钮弹出控制器
extension XLMainTabBarController:XLTabBarDelagete{

    func composeBtnClickPushController() {
        
       let nac = UINavigationController(rootViewController: XLComposeViewController())
   
    presentViewController(nac, animated: false, completion: nil)
        
    }

}







